#!/bin/bash
source /etc/profile

DATE=`date +%F`
DATE1=`date +%F -d yesterday`

#更新病毒库
freshclam
if [ $? -ne 0 ];then
	#查看系统类型
	LINUX_TYPE=$( lsb_release -d|awk '{print $2}')
	case $LINUX_TYPE in
		Ubuntu)
			echo "使用ubuntu系统安装clamav"
			apt-get update && apt-get install clamav
			;;
		Centos)
			echo "使用centos系统安装"
			yum install -y epel-release && yum install -y clamav
		
		*)
			echo "不支持该系统"
fi
#扫描病毒
clamscan -r /etc /bin /sbin /usr/bin /usr/sbin > /var/log/clamscan-$DATE.log 2>&1

if [ `grep "Infected files" /var/log/clamscan-$DATE.log|awk '{print $NF}' -ne 0` ];then
    # 报警功能
fi

rm -f /var/log/clamscan-$DATE1.log